<?php
namespace app\common\logic\cast\news;



use app\common\logic\cast\Base;



/**
 * Created by PhpStorm.
 * User: yangchunfu
 * Date: 2019/12/24
 * Time: 4:36 PM
 * 栏目
 */

class HotTime extends Base
{
    protected $apiHref = 'http://api01.idataapi.cn:8000/article/idataapi';
    public function __construct($options= [], $tag = '')
    {
        $ops = [
            'sourceRegion' => '中国',
        ];
        $options = array_merge($this->options, $ops, $options);
        parent::__construct($options, $tag);
    }


    /**
     * 获取插入字段
     */
    public function getField($v) {
        if (isset($v['imageUrls']) && is_array($v['imageUrls'])) {
            $data['imageUrls'] = array_shift($v['imageUrls']);
        }
        $data['news_id'] = isset($v['id']) ? $v['id'] : MD5($v['url']);
        $data['url'] = isset($v['url']) ? $v['url'] : '';
        $data['title'] = isset($v['title']) ? $v['title'] : '';
        $data['publishDate'] = isset($v['publishDate']) ? $v['publishDate'] : time();
        $data['viewCount'] = isset($v['viewCount']) ? $v['viewCount'] : 0;
        $data['likeCount'] = isset($v['likeCount']) ? $v['likeCount'] : 0;
        $data['commentCount'] = isset($v['commentCount']) ? $v['commentCount'] : 0;
        return $data;
    }

    /**
     * 调用接口
     * @param mixed $options
     */
    public function get($options = []) {
        $res1 = parent::get();
        $res2 = (new NewsWorld([], $this->tag))->get();


        $data = array_merge($res1, $res2);
        return $data;
    }
}